package com.museum;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import springfox.documentation.swagger.web.SwaggerResource;
import springfox.documentation.swagger.web.SwaggerResourcesProvider;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description:
 * @ClassName museum
 * @Author: 王瑞文
 * @Date: 2020/12/1 20:20
 */
@EnableZuulProxy
@EnableDiscoveryClient
@EnableSwagger2
@RefreshScope
@SpringBootApplication
public class GetWay80 {
    public static void main(String[] args) {
        SpringApplication.run(GetWay80.class, args);
    }

    // 添加文档来源
    @Component
    @Primary
    class DocumentationConfig implements SwaggerResourcesProvider {
        @Override
        public List<SwaggerResource> get() {
            List resources = new ArrayList<>();
            // app-itmayiedu-order
            //网关使用别名获取远程服务的swaggerAPI
            resources.add(swaggerResource("用户模块", "/museum-role/v2/api-docs", "2.0"));
            resources.add(swaggerResource("征集模块", "/museum-clue-yznl/v2/api-docs", "2.0"));
//            resources.add(swaggerResource("短信模块", "/museum-sms/v2/api-docs", "2.0"));
            resources.add(swaggerResource("入馆模块", "/museum-into-wyzz/v2/api-docs", "2.0"));
            resources.add(swaggerResource("短信模块", "/museum-sms/v2/api-docs", "2.0"));
            resources.add(swaggerResource("日志模块", "/museum-log/v2/api-docs", "2.0"));
            resources.add(swaggerResource("物品管控模块", "/museum-item/v2/api-docs", "2.0"));
            resources.add(swaggerResource("分类账模块","/museum-ledger/v2/api-docs","2.0"));
            return resources;
        }

        private SwaggerResource swaggerResource(String name, String location, String version) {
            SwaggerResource swaggerResource = new SwaggerResource();
            swaggerResource.setName(name);
            swaggerResource.setLocation(location);
            swaggerResource.setSwaggerVersion(version);
            return swaggerResource;
        }
    }
}
